package com.guxingke.gblog.dao.impl;

import java.util.List;

import com.guxingke.gblog.dao.CategoryDao;
import com.guxingke.gblog.dmo.Category;
import com.guxingke.gblog.dto.CategoryDto;

public class CategoryDaoImpl extends BaseDao implements CategoryDao {
	private CategoryDao dao = null;

	@Override
	public List<CategoryDto> all() throws Exception {
		begin();
		dao = session.getMapper(CategoryDao.class);

		List<CategoryDto> reuslt = dao.all();
		end();
		return reuslt;
	}

	@Override
	public void update(Category category) throws Exception {
		begin();
		dao = session.getMapper(CategoryDao.class);
		dao.update(category);
		end();

	}

	@Override
	public void save(Category category) throws Exception {
		begin();
		dao = session.getMapper(CategoryDao.class);
		dao.save(category);
		end();
	}

	@Override
	public void delete(Integer id) throws Exception {
		begin();
		dao = session.getMapper(CategoryDao.class);
		dao.delete(id);
		end();

	}

	@Override
	public Category get(Integer id) throws Exception {
		begin();
		dao = session.getMapper(CategoryDao.class);
		Category result = dao.get(id);
		end();

		return result;
	}

	@Override
	public boolean exist(int categoryId) throws Exception {
		begin();
		dao = session.getMapper(CategoryDao.class);
		boolean result = dao.exist(categoryId);
		end();
		return result;
	}

}
